﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/AdminSite.Master" Inherits="System.Web.Mvc.ViewPage<IPagedList<MensUnoShop.Models.ManagerSimpleMarket>>" %>
<%@ Import Namespace="MvcPaging"%>  
<%@ Import Namespace="MensUnoShop.Helpers" %>
<%@ Import Namespace="MensUnoShop.Areas.Admin.Helpers" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	MagaList
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript" language="javascript">
    function ChangeMarketStatus(mkguid, mktype) {
        //var shipno = $("#shipno").val();
        var jsonstring = { "mkguid": mkguid,"mktype":mktype };
        $.ajax({
            type: "POST",
            traditional: true,
            url: "/Admin/Product/ChangeMarketStatus",
            data: jsonstring,
            dataType: "json",
            success: function (data) {
                if (data.code == "200") {
                    alert("修改成功!");
                    //$("#btn_" + mkguid).remove();

                    if (data.response == "true")
                        $("#btn_" + mkguid).attr('value', '上架中');
                    else if (data.response == "false")
                        $("#btn_" + mkguid).attr('value', '下架中');
                }
                else
                    alert(data.response);
            }
        });
    }
</script>

	    <div id="main-content" class="hastable">
		    <div class="title title-spacing">
			    <h2>雜誌列表</h2>
		    </div>
            <%using (Html.BeginForm("MagaList", "Product", FormMethod.Post, new { @class = "shBox" }))
            {%>
                　　請輸入貨號或標題：<input type="text" name="query" value="" onfocus="this.value='';" />
                <input type="submit" class="submit" value="取得雜誌列表" />
                <input type="button" value="新增雜誌" onclick="javascript:location.href='Magazine/0'" />          
          <%} %>
          <br/>
            <ul class="pagination">
            <%= Html.UPager(Model.PageSize, Model.PageNumber, Model.TotalItemCount)%>
            </ul>
            <br />
            <table cellspacing="0" style="width:1000px;">
            <thead>
				<tr>
					<td style="width:80px;">商品貨號</td>
					<td style="width:300px">賣場標題</td>
                    <td style="width:120px">開賣時間</td>
                    <td style="width:120px">結束時間</td>
                    <td style="width:30px">訂價</td>
                    <td style="width:30px">售價</td>
                    <td style="width:30px">狀態</td>
                    <td style="width:30px">庫存</td>
                    <td></td>
				</tr>
			</thead>
            <%if (Model != null){%>
             <tbody>
            <%foreach (var item in Model)
            {  %>
        	    <tr align="center">
                    <td align="center" style="text-align: center" valign="middle"><%:item.SN %></td>
                    <td><%:item.TITLE %></td>
                    <td align="center" style="text-align: center" valign="middle"><%:item.SDATE.ToString("yyyy/MM/dd")%></td>
                    <td align="center" style="text-align: center" valign="middle"><%:item.EDATE.ToString("yyyy/MM/dd")%></td>
                    <td align="center" style="text-align: center" valign="middle"><%:item.SHOPPRICE%></td>
                    <td align="center" style="text-align: center" valign="middle"><%:item.PRICE %></td>
                    <td align="center" style="text-align: center" valign="middle"><input id="btn_<%:item.MKGUID %>" name="btn_<%:item.MKGUID %>" value="<%if(item.STATUS){%>上架中<%}else{ %>下架中<%} %>" type="button" onclick="ChangeMarketStatus('<%:item.MKGUID %>',<%:(int)item.TYPE %>);" /></td>
                    <%
                        var s = item.MSPLIST.FirstOrDefault();
                        int a = 0;
                          if(s!=null){
                              var ps = s.MSSLIST.FirstOrDefault();
                              if (ps != null)
                                  a = ps.SSTOCK;
                          } %>
                    <td align="center" style="text-align: center" valign="middle"><%:a %></td>
                    <td>
                        <a id="Market" name="Magazine" href="Magazine/<%:item.MKGUID %>">雜誌明細</a>  
                        <!--a id="MarketPicture" name="MarketPicture" href="MarketPictureDetail/<%:item.MKGUID %>">圖說</a> |--> 
                    </td>
                </tr>
            <%} %>
            </tbody>
            <%} %>
            </table>

            <ul class="pagination" style="margin-top:-60px;">
            <%= Html.UPager(Model.PageSize, Model.PageNumber, Model.TotalItemCount)%>
            </ul>
            <br/><br/>　
        </div>

</asp:Content>